// 有5名选手：选手ABCDE，10个评委分别对每一名选手打分，去除最高分，去除评委中最低分，取平均分。
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <ctime>
#include <algorithm>

using namespace std;

class Person
{
public:
    Person(string name, double score = 0)
    {
        this->_name = name;
        this->_score = score;
    }
    string _name;
    double _score;
};

class vecPerson
{
public:
    vecPerson();
    void creatPlayers();
    void setScore();
    void showScore() const;
    ~vecPerson();

    string prePlayerName;
    string sufPlayerName;
    vector<Person> v;
};

vecPerson::vecPerson(/* args */)
{
    prePlayerName = "Player_";
    sufPlayerName = "ABCDEF";
}

vecPerson::~vecPerson()
{
}

void vecPerson::creatPlayers()
{
    for (size_t i = 0; i < sufPlayerName.size(); i++)
    {
        string name = prePlayerName + sufPlayerName[i];
        Person p(name);
        v.push_back(p);
    }
}

void vecPerson::setScore()
{
    for (vector<Person>::iterator it = v.begin(); it != v.end(); ++it)
    {
        // score in deque
        deque<double> d;
        for (size_t i = 0; i < 10; i++)
        {
            double singleScore = rand() % 11 + 90;
            d.push_back(singleScore);
        }

        sort(d.begin(), d.end());
        d.pop_back();
        d.pop_front();
        double sum = 0;
        for (deque<double>::iterator dit = d.begin(); dit != d.end(); ++dit)
        {
            sum += *dit;
        }
        double score = sum / d.size();
        it->_score = score;
    }
}

void vecPerson::showScore() const
{
    for (auto it = v.begin(); it != v.end(); ++it)
    {
        cout << "name: " << it->_name << "  "
             << "score: " << it->_score << endl;
    }
}

template<class T>
void abc()
{
    T temp;
    return T;
}

int main()
{
    // Random number seed
    srand((unsigned int)time(NULL));

    // 1. creatPlayers
    vecPerson vP; //存放选手容器
    vP.creatPlayers();
    // 2. setScore
    vP.setScore();
    // 3. showScore
    vP.showScore();

    return 1;
}


